package sunyu.demo.mina;

import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.session.IoSession;
import sunyu.toolkit.mina.SocketClientTemplate;

/**
 * @author 孙宇
 */
public class MySocketClient extends SocketClientTemplate {
    public MySocketClient(String host, int port) {
        super(host, port);
    }

    @Override
    public void messageReceived(IoSession iosession, Object message) throws Exception {
        IoBuffer bbuf = (IoBuffer) message;
        byte[] byten = new byte[bbuf.limit()];
        bbuf.get(byten, bbuf.position(), bbuf.limit());
        System.out.println("客户端收到消息:");
        System.out.println(byten);
    }
}
